clear all
set more off

set maxvar 32000
set matsize 11000
*************************************************************************************************
*set scheme aspen, perm
grstyle init
grstyle set plain, horizontal grid

use "$folder/data/data_ready.dta", clear

cd "$folder/output/figures"
local x=18

*******************
* All figures in Appendix D-F
*******************


*************** Figures A16- Lgraphs ***************
import delimited using "$folder/data/input/state_year_18_all_topics.csv", clear

* Currently topics are vertical - must reshape into wide format
keep state year num_topics topic provision
reshape wide  provision, i( state year num_topics) j(topic)


* biennium includes stated year and previous year
gen biennium =  year + mod(year,2)
replace year = biennium


* Collapsing to biennium level

collapse (mean) provision* , by(state year)

* Setting time series

egen statefe = group(state)
gen statename1 = state
drop state
gen state = statefe

tsset statefe year, delta(2)

* Crating local macros for all variable combinations and categories

local provisions provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out0  provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out1  provision0 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out2  provision0 provision1 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out3  provision0 provision1 provision2 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out4  provision0 provision1 provision2 provision3 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out5  provision0 provision1 provision2 provision3 provision4 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out6  provision0 provision1 provision2 provision3 provision4 provision5 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out7  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out8  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out9  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision10 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out10  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision11 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out11  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision12 provision13 provision14 provision15 provision16 provision17

local provision_out12  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision13 provision14 provision15 provision16 provision17

local provision_out13  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision14 provision15 provision16 provision17

local provision_out14  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision15 provision16 provision17

local provision_out15  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision16 provision17

local provision_out16  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision17

local provision_out17  provision0 provision1 provision2 provision3 provision4 provision5 provision6 provision7 provision8 provision9 provision10 provision11 provision12 provision13 provision14 provision15 provision16


* Replacing missing values with lags

foreach x of varlist `provisions' {

replace `x' = L.`x' if missing(`x')
replace `x' = L2.`x' if missing(`x')
replace `x' = L3.`x' if missing(`x')
replace `x' = L4.`x' if missing(`x')
replace `x' = L5.`x' if missing(`x')
}


* Generating log and first difference of all variables

foreach x of varlist `provisions'{

gen log_`x' = log(1+`x')
gen growth_18`x' = D.log_`x'

}

* Generating total growth by category-topic and growth in other states

foreach x of varlist `provisions' {

sort year 

by year: egen growth_sum_18`x' = total(growth_18`x')

by year: gen growth_loo_18`x' = (growth_sum_18`x' - growth_18`x') / 17

by year: gen growth_loo1_18`x' = (growth_sum_18`x') / 18

}


*************Topic 0************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out0')

foreach x of varlist `provision_out0' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out0' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out0' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_0 = shock_summ18prov/18
gen shock1_prov_18_0 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18

*************Topic 1************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out1')

foreach x of varlist `provision_out1' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out1' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out1' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_1 = shock_summ18prov/18
gen shock1_prov_18_1 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18

*************Topic 2************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out2')

foreach x of varlist `provision_out2' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out2' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out2' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_2 = shock_summ18prov/18
gen shock1_prov_18_2 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 3************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out3')

foreach x of varlist `provision_out3' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out3' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out3' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_3 = shock_summ18prov/18
gen shock1_prov_18_3 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 4************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out4')

foreach x of varlist `provision_out4' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out4' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out4' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_4 = shock_summ18prov/18
gen shock1_prov_18_4 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18



*************Topic 5************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out5')

foreach x of varlist `provision_out5' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out5' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out5' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_5 = shock_summ18prov/18
gen shock1_prov_18_5 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18



*************Topic 6************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out6')

foreach x of varlist `provision_out6' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out6' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out6' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_6 = shock_summ18prov/18
gen shock1_prov_18_6 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18



*************Topic 7************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out7')

foreach x of varlist `provision_out7' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out7' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out7' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_7 = shock_summ18prov/18
gen shock1_prov_18_7 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 8************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out8')

foreach x of varlist `provision_out8' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out8' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out8' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_8 = shock_summ18prov/18
gen shock1_prov_18_8 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 9************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out9')

foreach x of varlist `provision_out9' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out9' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out9' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_9 = shock_summ18prov/18
gen shock1_prov_18_9 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 10************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out10')

foreach x of varlist `provision_out10' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out10' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out10' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_10 = shock_summ18prov/18
gen shock1_prov_18_10 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 11************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out11')

foreach x of varlist `provision_out11' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out11' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out11' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_11 = shock_summ18prov/18
gen shock1_prov_18_11 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 12************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out12')

foreach x of varlist `provision_out12' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out12' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out12' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_12 = shock_summ18prov/18
gen shock1_prov_18_12 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 13************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out13')

foreach x of varlist `provision_out13' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out13' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out13' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_13 = shock_summ18prov/18
gen shock1_prov_18_13 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 14************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out14')

foreach x of varlist `provision_out14' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out14' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out14' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_14 = shock_summ18prov/18
gen shock1_prov_18_14 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 15************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out15')

foreach x of varlist `provision_out15' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out15' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out15' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_15 = shock_summ18prov/18
gen shock1_prov_18_15 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 16************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out16')

foreach x of varlist `provision_out16' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out16' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out16' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_16 = shock_summ18prov/18
gen shock1_prov_18_16 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18


*************Topic 17************************************
*Generating shares of each category and topic
egen provisions_18 = rowtotal(`provision_out17')

foreach x of varlist `provision_out17' {
gen share18_`x' = `x' / provisions_18
}
* Generating average of initial 5 year share
sort statefe year
foreach x of varlist `provision_out17' {

bys statefe: gen topic_initial1_`x' = share18_`x'[1] 
bys statefe: gen topic_initial2_`x' = share18_`x'[2] 
bys statefe: gen topic_initial3_`x' = share18_`x'[3] 
bys statefe: gen topic_initial4_`x' = share18_`x'[4] 
bys statefe: gen topic_initial5_`x' = share18_`x'[5] 
bys statefe: gen topic_initial_`x' = (topic_initial1_`x' + topic_initial2_`x'+topic_initial3_`x'+topic_initial4_`x'+topic_initial5_`x')/5

bys statefe: gen share18_prev`x'=share18_`x'[_n-1]

}
* Generating Shocks for each category
foreach x of varlist `provision_out17' {
	
gen shock_sum_18`x' =  topic_initial_`x' * growth_loo_18`x'
gen shock_sum1_18`x' =  topic_initial_`x' * growth_loo1_18`x'

}
egen shock_summ18prov = rowtotal(shock_sum_18prov*)
egen shock_summ118prov = rowtotal(shock_sum1_18prov*)

* / divide each category's shock by 18 topics
gen shock_prov_18_17 = shock_summ18prov/18
gen shock1_prov_18_17 = shock_summ118prov/18

drop topic_initial* shock_sum* share18* provisions_18

foreach i of numlist 0/17 {
egen st_shock_prov`i' = std(shock_prov_18_`i')

}

keep statename1  year st_shock_prov*

rename statename1 state_abbrev

merge 1:1 state_abbrev year using "$folder/data/data_ready"
drop _merge


eststo clear

foreach i of numlist 0/17 {

eststo:   ivreghdfe growth_pc  (log_provisions_18 = st_shock_prov`i'), absorb(state year)  cl(state)

}

coefplot (est1, mlabel("No Topic 0")) (est2, mlabel("No Topic 1")) (est3, mlabel("No Topic 2")) (est4, mlabel("No Topic 3")) (est5, mlabel("No Topic 4")) (est6, mlabel("No Topic 5")) (est7, mlabel("No Topic 6")) (est8, mlabel("No Topic 7")) (est9, mlabel("No Topic 8")) (est10, mlabel("No Topic 9")) (est11, mlabel("No Topic 10")) (est12, mlabel("No Topic 11")) (est13, mlabel("No Topic 12")) (est14, mlabel("No Topic 13")) (est15, mlabel("No Topic 14")) (est16, mlabel("No Topic 15")) (est17, mlabel("No Topic 16")) (est18, mlabel("No Topic 17")), nokey xline(0, lcolor(gray) lpattern(dash)) ci(90) ciopts( lpattern(shortdash_dot)) title() ylabel("") 

cd "$folder/output/figures"

graph export Figure_A16_leaveout.pdf, replace

*************** Figure A17 binscatt_donation ***************
use "$folder/data/data_ready.dta", clear

cd "$folder/output/figures"

gen log_donations = log(donations)

binscatter log_donations shock_prov18, absorb(state) controls(i.year) xtitle(Shock to Provisions) ytitle(Campaign Contributions) text(16.6 -.7   "Slope = 0.292" "(s.e. = .458)" "F-stat =0.41" , place(se) just(left) margin(l+4 t+1 b+1) width(25) ) xsize(8)
graph export Figure_A17_binscatt_donation.pdf, replace

*************** Figures A18 time ***************

local x=18

preserve

gen statute_regulation= provisions_18/word_count_reg
gen log_statute_regulation = log(statute_regulation)

*Time Series Plot

replace log_word_count_reg=. if year<2002

keep if year>1964
keep if year<2011
collapse (mean)  log_word_count_18 log_word_count_reg log_word_count_courts, by(year)

label variable log_word_count_18 "Statute Words"
label variable log_word_count_reg "Regulation Words"
label variable log_word_count_courts "Court Opinion Words"

twoway line  log_word_count_18 log_word_count_reg log_word_count_courts year, lcolor(gs10 dkgreen dknavy dkorange) lpattern(solid solid solid solid)
graph export Figure_A18_time.pdf, replace

restore
*************** Figures A19 binscatt_reg_state ***************

binscatter log_provisions_18 log_word_count_reg, absorb(year)  xtitle(Log State Regulation Words) ytitle(Log Provisions) text(10 11.5 "Slope = 0.126" "(s.e. = .054)" "F-stat =5.42" , place(se) just(left) margin(l+4 t+1 b+1) width(25) ) xsize(8)
graph export Figure_A19A_binscatt_reg_state.pdf, replace

binscatter log_provisions_18 log_word_count_reg, absorb(state) control(i.year)  xtitle(Log State Regulation Words) ytitle(Log Provisions) text(9.25 11 "Slope = -.0215" "(s.e. = .0152)" "F-stat =2" , place(se) just(left) margin(l+4 t+1 b+1) width(25) ) xsize(8)
graph export Figure_A19B_binscatt_reg_state1.pdf, replace

*************** Figures A20 binscatt_court ***************

binscatter log_provisions_18 log_word_count_courts, absorb(year)  xtitle(Log Court Opinion Words) ytitle(Log Provisions) text(10 13.2 "Slope = .3968" "(s.e. = .1066)" "F-stat =13.85" , place(se) just(left) margin(l+4 t+1 b+1) width(25) ) xsize(8)
graph export Figure_A20A_binscatt_court.pdf, replace

binscatter log_provisions_18 log_word_count_courts, absorb(state) control(i.year)  xtitle(Log Court Opinion Words) ytitle(Log Provisions) text(9.25 14 "Slope = .0413" "(s.e. = .0712)" "F-stat =0.34" , place(se) just(left) margin(l+4 t+1 b+1) width(25) ) xsize(8)
graph export Figure_A20B_binscatt_court1.pdf, replace


*************** Figures A21 binscatt_fed_grow***************
gen log_fed_reg = log(fed_reg)

binscatter log_provisions_18 log_fed_reg, absorb(state) controls(i.year) xtitle(Log Federal Provisions) ytitle(Log Provisions) text(9.4 13.63 "Slope = 0.41" "(s.e. = .29)" "F-stat =2.02" , place(se) just(left) margin(l+4 t+1 b+1) width(25) ) xsize(8)
graph export Figure_A21_binscatt_fed_prov.pdf, replace


*******************
* All tables in Appendix D-F
*******************
cd "$folder/output/tables"

label variable log_provisions_18 "Log Provisions"
label variable log_word_count_18 "Log State Statute Words"
label variable log_cond_list_prov_18 "Log Contingent Provisions" 
label variable log_non_cond_list_prov_18 "Log Non-Contingent Provisions" 
label variable shock_prov18 "Shock to Provisions"
label variable shock_cond_list_prov18 "Shock to Contingent Provisions"
label variable shock_non_cond_list_prov18 "Shock to Non-Contingent Provisions"
label variable log_fed_reg "Log Federal Regulation"
xtset state year, yearly delta(2)

***************Table A.15: Effect of Legislative Output on Economic Growth (OLS) ***************

foreach x in 18  {


* 1 // year FE, state FE
reghdfe growth_pc log_provisions_`x', absorb(state year) cl(state)
outreg2 using Table_A15_OLS, excel replace label  ctitle(OLS)  nocons addtext(State FE, X, Time FE, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 2 // year, state, state trend
reghdfe growth_pc  log_provisions_`x', absorb(state##c.year year)  cl(state)
outreg2 using Table_A15_OLS, excel append label  ctitle(OLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(R-squared,  e(r2))  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 3 // initial growth, initial GSP, and initial GSP per capita, interacted with year
reghdfe growth_pc  log_provisions_`x', absorb(state year##c.(gsp_initial  growth_initial gsp_pc_initial)) cl(state)
outreg2 using Table_A15_OLS, excel append label  ctitle(OLS)  nocons addtext(State FE, X, Time FE, X, Initial Econ x Time, X) addstat(R-squared,  e(r2))  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 4// initial sector shares (4 PCs), interacted with year, p=.04
reghdfe growth_pc  log_provisions_`x', absorb(state  year##c.(pc1_sectors pc2_sectors pc3_sectors pc4_sectors)) cl(state)
outreg2 using Table_A15_OLS, excel append label ctitle(OLS)  nocons addtext(State FE, X, Time FE, X, PC Sector Shares x Time, X) addstat(R-squared,  e(r2))  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 5 // initial population / demographics X year
reghdfe growth_pc  log_provisions_`x', absorb(state year##c.(initial_lpop initial_lpop2  initial_urban initial_foreign)) cl(state)
outreg2 using Table_A15_OLS, excel append label ctitle(OLS)  nocons addtext(State FE, X, Time FE, X, Pre-Period Demog x Time, X) addstat(R-squared,  e(r2))   alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 6 // current-period topic controls
reghdfe growth_pc  log_provisions_`x', absorb(state year one#c.(share`x'_provision*)) cl(state)
outreg2 using Table_A15_OLS, excel append label  ctitle(OLS)  nocons addtext(State FE, X, Time FE, X, Topic Shares, X) addstat(R-squared,  e(r2))   alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 7 // all
reghdfe growth_pc  log_provisions_`x', absorb(state##c.year year##c.(gsp_initial  growth_initial gsp_pc_initial pc1_sectors pc2_sectors pc3_sectors pc4_sectors initial_lpop initial_lpop2  initial_urban initial_foreign) one#c.(share`x'_provision* L.logexp L.logexp2 L.loglegexp L.loglegexp2 L.growth_pc)) cl(state)
outreg2 using Table_A15_OLS, excel append label  ctitle(OLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X, Initial Econ x Time, X, PC Sector Shares x Time, X, Pre-Period Demog x Time, X, Govt Expenditure, X, Topic Shares, X, Lagged Growth, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

}



***************Table A.16: Effect of Legislative Output on Economic Growth (Reduced Form) ***************


foreach x in 18  {

* 2 // year FE, state FE
reghdfe growth_pc shock_prov`x' , absorb(state year) cl(state)
outreg2 using Table_A16_RF, excel replace label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X) addstat (R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 3 // year, state, state trend
reghdfe growth_pc shock_prov`x', absorb(state##c.year year)  cl(state)
outreg2 using Table_A16_RF, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 4 // initial growth, initial GSP, and initial GSP per capita, interacted with year
reghdfe growth_pc shock_prov`x', absorb(state year##c.(gsp_initial  growth_initial gsp_pc_initial)) cl(state)
outreg2 using Table_A16_RF, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Initial Econ x Time, X) addstat( R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 5 // initial sector shares (4 PCs), interacted with year, p=.04
reghdfe growth_pc shock_prov`x', absorb(state  year##c.(pc1_sectors pc2_sectors pc3_sectors pc4_sectors)) cl(state)
outreg2 using Table_A16_RF, excel append label ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, PC Sector Shares x Time, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 6 // initial population / demographics X year
reghdfe growth_pc shock_prov`x', absorb(state year##c.(initial_lpop initial_lpop2  initial_urban initial_foreign)) cl(state)
outreg2 using Table_A16_RF, excel append label ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Pre-Period Demog x Time, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 8 // current-period topic controls
reghdfe growth_pc shock_prov`x', absorb(state year one#c.(share`x'_provision*)) cl(state)
outreg2 using Table_A16_RF, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Topic Share, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 9 // all
reghdfe growth_pc shock_prov`x', absorb(state##c.year year##c.(gsp_initial  growth_initial gsp_pc_initial pc1_sectors pc2_sectors pc3_sectors pc4_sectors initial_lpop initial_lpop2  initial_urban initial_foreign) one#c.(share`x'_provision* L.logexp L.logexp2 L.loglegexp L.loglegexp2)) cl(state)
outreg2 using Table_A16_RF, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X, Initial Econ x Time, X, PC Sector Shares x Time, X, Pre-Period Demog x Time, X, Govt Expenditure, X, Topic Share, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
}


***************Table A.17: Effect of Legislative Output on Economic Growth, Leads and Lags ***************

foreach x in 18  {

** Table - Effect of legislation on growth - leads and lags - controls

*1 Lead + cont
ivreghdfe growth_pc (log_provisions_`x' F_log_provisions_`x' = shock_prov`x' F_shock_prov`x'), absorb(state year)  cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel replace label   stat(coef  pval)   ctitle(2SLS Lead + Cont)   nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*2 Lead + cont (trends)
ivreghdfe growth_pc (log_provisions_`x' F_log_provisions_`x' = shock_prov`x' F_shock_prov`x'), absorb(state##c.year year)  cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label   stat(coef  pval)  ctitle(2SLS Lead + Cont)   nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*3 Lead + cont all
ivreghdfe growth_pc  (log_provisions_`x' F_log_provisions_`x' = shock_prov`x' F_shock_prov`x'), absorb(state##c.year year##c.(gsp_initial  growth_initial gsp_pc_initial pc1_sectors pc2_sectors pc3_sectors pc4_sectors initial_lpop initial_lpop2  initial_urban initial_foreign) one#c.(share`x'_provision* L.logexp L.logexp2 L.loglegexp L.loglegexp2)) cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label  stat(coef  pval)   ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X, Initial Econ x Time, X, PC Sector Shares x Time, X, Pre-Period Demog x Time, X, Govt Expenditure, X, Topic Share, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*4  Lag + Cont
ivreghdfe growth_pc (log_provisions_`x' L_log_provisions_`x' = shock_prov`x' L_shock_prov`x'), absorb(state year)  cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label  stat(coef  pval)    ctitle(2SLS Lag + Cont)    nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*5 2 Lags + Cont
ivreghdfe growth_pc (log_provisions_`x' L_log_provisions_`x' L2_log_provisions_`x' = shock_prov`x' L_shock_prov`x' L2_shock_prov`x'), absorb(state year)   cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label   stat(coef  pval)   ctitle(2SLS 2 Lags + Cont)   nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*6 Lag + Cont (trends)
ivreghdfe growth_pc (log_provisions_`x' L_log_provisions_`x' = shock_prov`x' L_shock_prov`x'), absorb(state##c.year year)  cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label  stat(coef  pval)   ctitle(2SLS Lag + Cont)    nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*7 Lag + Cont
ivreghdfe growth_pc  (log_provisions_`x' L_log_provisions_`x' = shock_prov`x' L_shock_prov`x'), absorb(state##c.year year##c.(gsp_initial  growth_initial gsp_pc_initial pc1_sectors pc2_sectors pc3_sectors pc4_sectors initial_lpop initial_lpop2  initial_urban initial_foreign) one#c.(share`x'_provision* L.logexp L.logexp2 L.loglegexp L.loglegexp2)) cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label  stat(coef  pval)   ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X, Initial Econ x Time, X, PC Sector Shares x Time, X, Pre-Period Demog x Time, X, Govt Expenditure, X, Topic Share, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*8 RF
reghdfe growth_pc shock_prov`x' L_shock_prov`x', absorb(state year)  cl(state)
outreg2 using Table_A17_Leads_Lags_all, excel append label   ctitle(RF Lead + Cont)   nocons addtext(State FE, X, Time FE, X) addstat( R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
}


*************** Table A.18 - Main 2SLS with different SE clustering ***************


**** With no clustering

* 2 // year FE, state FE
ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year) 
outreg2 using Table_A18_cluster, excel replace label keep(log_provisions_18) ctitle(no clustering)  addtext(State FE, X, Time FE, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
* 3 // year, state, state trend
ivreghdfe growth_pc  (log_provisions_18 = shock_prov18), absorb(state##c.year year)  
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(no clustering)  addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


**** Two-way clustering

* 2 // year FE, state FE
ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year) cl(state year)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(Two way state year)  addtext(State FE, X, Time FE, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
* 3 // year, state, state trend
ivreghdfe growth_pc  (log_provisions_18 = shock_prov18), absorb(state##c.year year) cl(state year)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(Two way state year)  addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2  nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

**** Initial Topic clustering 12

* 2 // year FE, state FE
ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year) cl(cluster12)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(topic12)  addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
* 3 // year, state, state trend
ivreghdfe growth_pc  (log_provisions_18 = shock_prov18), absorb(state##c.year year)  cl(cluster12)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(topic12)  addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

**** Initial Topic clustering 16

* 2 // year FE, state FE
ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year) cl(cluster16)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(topic16)  addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
* 3 // year, state, state trend
ivreghdfe growth_pc  (log_provisions_18 = shock_prov18), absorb(state##c.year year)  cl(cluster16)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(topic16)  addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

**** Initial Topic clustering 20

* 2 // year FE, state FE
ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year) cl(cluster20)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(topic20)  addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
* 3 // year, state, state trend
ivreghdfe growth_pc  (log_provisions_18 = shock_prov18), absorb(state##c.year year)  cl(cluster20)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(topic20)  addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

**** AKM
preserve

drop topic_init_provision2
drop if missing(growth_pc)
drop if missing(log_provisions_18)

tab statefe, generate(statedum)
tab year, generate(yeardum)

ivreg_ss growth_pc, endogenous_var(log_provisions_18) shiftshare_iv(shock_prov18) share_varlist(topic_init*) control_varlist(yeardum*) cluster_var(cluster20)
outreg2 using Table_A18_cluster, excel append label keep(log_provisions_18) ctitle(AKM)  addtext(Time FE, X) addstat(R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nocons nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

restore


*************** Table A.19: Effect of Legislative Output on Economic Growth - Topic Controls ***************
local vartopic topic_init_provision15 topic_init_provision13 topic_init_provision9 topic_init_provision3 

ivreghdfe growth_pc  (log_provisions_18 = shock_prov18),  absorb(one#c.(`vartopic') state year) cl(state)
outreg2 using Table_A19_topicFE, excel replace label   ctitle(2SLS)   keep (log_provisions_18)   addtext(State FE, X, Time FE, X, Frequent Topic FE, X) alpha(0.01, 0.05, 0.1) addstat(First Stage F-stat, e(rkf)) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


ivreghdfe growth_pc  (log_provisions_18 = shock_prov18),  absorb(one#c.(`vartopic') state##c.year year) cl(state)
outreg2 using Table_A19_topicFE, excel append label   ctitle(2SLS)   keep (log_provisions_18)   addtext(State FE, X, Time FE, X, State Trends, X, Frequent Topic FE, X) alpha(0.01, 0.05, 0.1) addstat(First Stage F-stat, e(rkf)) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

local pca pc1_compl18

ivreghdfe growth_pc  (log_provisions_18 = shock_prov18),  absorb(one#c.(`pca') state year) cl(state)
outreg2 using Table_A19_topicFE, excel append label   ctitle(2SLS)   keep (log_provisions_18)   addtext(State FE, X, Time FE, X, PCA, X) alpha(0.01, 0.05, 0.1) addstat(First Stage F-stat, e(rkf)) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


ivreghdfe growth_pc  (log_provisions_18 = shock_prov18),  absorb(one#c.(`pca') state##c.year year) cl(state)
outreg2 using Table_A19_topicFE, excel append label   ctitle(2SLS)   keep (log_provisions_18)   addtext(State FE, X, Time FE, X, State Trends, X, PCA, X) alpha(0.01, 0.05, 0.1) addstat(First Stage F-stat, e(rkf)) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*************** Table A.20: Effect of Legislative Output on Economic Growth - Different Number of Topics***************

foreach x in 6 12 24 30 36 42 48 {
	global if=""
	if `x'==6 {
		global append="replace"
	}
	else{
		global append="append"
	}
* 1 // year FE, state FE
ivreghdfe growth_pc (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A20_othertopics, excel $append label  ctitle(2SLS_`x')  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


}

*************** Table A.21: Effect of Detail on Growth – Adjusting for Words or Pages***************

foreach x in 18 {  

* 1 // year FE, state FE - word
ivreghdfe growth_pc (log_word_count_`x' = shock_word`x') , absorb(state year) cl(state)
outreg2 using Table_A21_Words_Pages, excel replace label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 2 // year, state, state trend - word 
ivreghdfe growth_pc  (log_word_count_`x' = shock_word`x') , absorb(state##c.year year)  cl(state)
outreg2 using Table_A21_Words_Pages, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 5 // year, state, state trend - word control
ivreghdfe growth_pc  (log_provisions_`x' = shock_prov`x') log_word_count_`x' , absorb(state##c.year year)  cl(state)
outreg2 using Table_A21_Words_Pages, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 6 // year, state, state trend - pages control
ivreghdfe growth_pc  (log_provisions_`x' = shock_prov`x') log_page , absorb(state##c.year year)  cl(state)
outreg2 using Table_A21_Words_Pages, excel append label  ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

}

***************Table A.22: Main Results, Controlling for Amend/Repeal Share***************

* Amend

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) log_share_amend_clause_count, absorb(state year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel replace label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Amend Share, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) log_share_amend_clause_count, absorb(state##c.year year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Amend Share, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) log_share_amend_clause_count, absorb(state year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Amend Share, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) log_share_amend_clause_count, absorb(state##c.year year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Amend Share, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* Repeal

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) log_share_repeal_clause_count, absorb(state year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Repeal Share, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) log_share_repeal_clause_count, absorb(state##c.year year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Repeal Share, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) log_share_repeal_clause_count, absorb(state year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Repeal Share, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) log_share_repeal_clause_count, absorb(state##c.year year) cl(state)
outreg2 using Table_A22_Amend_Repeal_grow, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Repeal Share, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


***************Table A.23: Controlling for Campaign Finance Rules***************

egen campaignyear = group(contributionslimit year)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year campaignyear) cl(state)
outreg2 using Table_A23_Fed_Reg_grow_contr1, excel replace label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(Contribution x Time, X, State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state##c.year year campaignyear) cl(state)
outreg2 using Table_A23_Fed_Reg_grow_contr1, excel append label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(Contribution x Time, X, State FE, X,  State-Specific Trends, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) , absorb(state year campaignyear) cl(state)
outreg2 using Table_A23_Fed_Reg_grow_contr1, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(Contribution x Time, X, State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) , absorb(state##c.year year campaignyear) cl(state)
outreg2 using Table_A23_Fed_Reg_grow_contr1, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(Contribution x Time, X, State FE, X,  State-Specific Trends, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


***************Table A.24: Effect of Contingencies on Additional Economic Variables***************

*1 GSP Growth
ivreghdfe growth_gsp  (log_provisions_18 = shock_prov18) , absorb(state year) cl(state)
outreg2 using Table_A24_other_out_cont, excel replace label  ctitle(GSP)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*2 Population Growth
ivreghdfe lpop_D  (log_provisions_18 = shock_prov18)  , absorb(state year) cl(state)
outreg2 using Table_A24_other_out_cont, excel append label ctitle(Pop)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*3 Employment Growth
ivreghdfe lcbp_emp_D (log_provisions_18 = shock_prov18) , absorb(state year) cl(state)
outreg2 using Table_A24_other_out_cont, excel append label  ctitle(Empl)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*4 Profits Growth
ivreghdfe lprofits_mill_D  (log_provisions_18 = shock_prov18)  , absorb(state year) cl(state)
outreg2 using Table_A24_other_out_cont, excel append label ctitle(Profit)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*5 Income PC
ivreghdfe loginc_D  (log_provisions_18 = shock_prov18)  , absorb(state year) cl(state)
outreg2 using Table_A24_other_out_cont, excel append label ctitle(Inc)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*6 Establishment Growth
ivreghdfe lestab_D  (log_provisions_18 = shock_prov18) , absorb(state year) cl(state)
outreg2 using Table_A24_other_out_cont, excel append label  ctitle(Est)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


***************Table A.25: Effect of Legislative Output on Additional Economic Variables II***************

foreach x in 18  {

*1 Small Establishment Growth
ivreghdfe lestab_small_D (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A25_other_out, excel replace label  ctitle(Small Est)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*2 Medium Establishment Growth

ivreghdfe lestab_mid_D (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A25_other_out, excel append label  ctitle(Med Est)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)



*3 Large Establishment Growth

ivreghdfe lestab_large_D (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A25_other_out, excel append label  ctitle(Large Est)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*4 Profits Ratio Growth

ivreghdfe profit_ratio_D (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A25_other_out, excel append label  ctitle(Profit Ratio)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*5 Large Ratio Growth

ivreghdfe large_ratio_D (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A25_other_out, excel append label  ctitle(Large Ratio)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*6 Large Small Ratio Growth

ivreghdfe large_small_ratio_D (log_provisions_`x' = shock_prov`x') , absorb(state year) cl(state)
outreg2 using Table_A25_other_out, excel append label  ctitle(Large Small Ratio)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

}


***************Table A.26: Legislative Output Shock Does Not Affect Spending, Taxes, or Political Control***************
gen log_tax = log(1+tax)
foreach x in 18 {  

*1 govt spending Reduced Form
reghdfe logexp shock_prov`x' , absorb(state year) cluster(state)
outreg2 using Table_A26_FS_RF_other, excel replace label  keep(shock_prov`x')  ctitle(Reduced Form) addstat(R-squared,  e(r2)) nocons addtext(State FE, X, Time FE, X) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*2 govt spending 2SLS
ivreghdfe logexp  (log_provisions_`x' = shock_prov`x'), absorb(state year)  cl(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(log_provisions_`x')  ctitle(2SLS) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2))   nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1) 


*3 Legis spending Reduced Form
reghdfe loglegexp shock_prov`x' , absorb(state year) cluster(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(shock_prov`x')  ctitle(Reduced Form)  addstat(R-squared,  e(r2))  nocons addtext(State FE, X, Time FE, X) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*4 Legis spending 2SLS
ivreghdfe loglegexp  (log_provisions_`x' = shock_prov`x'), absorb(state year)  cl(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(log_provisions_`x')  ctitle(2SLS) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2))   nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*5 tax Reduced Form
reghdfe log_tax shock_prov`x' , absorb(state year) cluster(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(shock_prov`x')  ctitle(Reduced Form)    nocons addtext(State FE, X, Time FE, X) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1) addstat( R-squared,  e(r2)) 

*6 tax 2SLS
ivreghdfe log_tax  (log_provisions_`x' = shock_prov`x'), absorb(state year)  cl(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(log_provisions_`x')  ctitle(2SLS) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2))   nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1) 


*7 Dem Control
reghdfe dem_control shock_prov`x' , absorb(state year) cluster(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(shock_prov`x')  ctitle(Reduced Form)    nocons addtext(State FE, X, Time FE, X) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1) addstat( R-squared,  e(r2)) 

*8 Dem Control 2SLS
ivreghdfe dem_control  (log_provisions_`x' = shock_prov`x'), absorb(state year)  cl(state)
outreg2 using Table_A26_FS_RF_other, excel append label  keep(log_provisions_`x')  ctitle(2SLS)  addstat(First Stage F-stat, e(rkf), R-squared,  e(r2))  nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)
}

*************** Table A.27: Reduced Form Effect of Legislation Instrument on State Regulatory Output***************

reghdfe log_word_count_reg shock_prov18, absorb(state year) cl(state) 
outreg2 using Table_A27_statereg, excel append replace  ctitle(State Reg)  nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

reghdfe log_word_count_reg shock_prov18, absorb(state##c.year year) cl(state) 
outreg2 using Table_A27_statereg, excel append label ctitle(State Reg)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*************** Table A.28: Controlling For State Regulation, Interacted with Time FE***************

bysort state : egen avg_word_count_reg=mean(log_word_count_reg)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year##c.avg_word_count_reg) cl(state)
outreg2 using Table_A28_statereg_trend, excel replace label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State Reg x Time, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) , absorb(state year##c.avg_word_count_reg) cl(state)
outreg2 using Table_A28_statereg_trend, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, State Reg x Time, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


***************Table A.29: Reduced Form Effect of Legislation Instrument on Judicial Opinion Output***************
reghdfe log_word_count_courts shock_prov18, absorb(state year) cl(state) 
outreg2 using Table_A29_judicial_opinion, excel replace label  ctitle(Court Case)  nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

reghdfe log_word_count_courts shock_prov18, absorb(state##c.year year) cl(state) 
outreg2 using Table_A29_judicial_opinion, excel append label ctitle(Court Case)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


***************Table A.30: Controlling for Legal Detail in State Court Opinions***************
foreach x in word_count_courts  {


ivreghdfe growth_pc (log_provisions_18 = shock_prov18) log_`x', absorb(state##c.year year) cl(state)
outreg2 using Table_A30_courtopinion_control, excel replace label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Court Words, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) log_`x', absorb(state##c.year year) cl(state)
outreg2 using Table_A30_courtopinion_control, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Court Words, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

}


*************** Table A.31: Federal Judicial Circuits***************

**judicial circuits
gen circuit = .
replace circuit = 1 if state_abbrev == "ME" | state_abbrev == "MA" | state_abbrev == "NH" | state_abbrev == "PR" | state_abbrev == "RI"
replace circuit = 2 if state_abbrev == "CT" | state_abbrev == "NY" | state_abbrev == "VT"
replace circuit = 3 if state_abbrev == "DE" | state_abbrev == "NJ" | state_abbrev == "PA"
replace circuit = 4 if state_abbrev == "MD" | state_abbrev == "NC" | state_abbrev == "SC" | state_abbrev == "VA" | state_abbrev == "WV"
replace circuit = 5 if (state_abbrev == "AL" | state_abbrev == "FL" | state_abbrev == "GA") & year < 1982 	// Previously from circuit 5
replace circuit = 5 if state_abbrev == "LA" | state_abbrev == "MS" | state_abbrev == "TX"
replace circuit = 6 if state_abbrev == "KY" | state_abbrev == "MI" | state_abbrev == "OH" | state_abbrev == "TN"
replace circuit = 7 if state_abbrev == "IL" | state_abbrev == "IN" | state_abbrev == "WI"
replace circuit = 8 if state_abbrev == "AR" | state_abbrev == "IA" | state_abbrev == "MN" | state_abbrev == "MO" | state_abbrev == "NE" | state_abbrev == "ND" | state_abbrev == "SD"
replace circuit = 9 if state_abbrev == "AK" | state_abbrev == "AZ" | state_abbrev == "CA" | state_abbrev == "HI" | state_abbrev == "ID" | state_abbrev == "MT" | state_abbrev == "NV" | state_abbrev == "OR" | state_abbrev == "WA"
replace circuit = 10 if state_abbrev == "CO" | state_abbrev == "KS" | state_abbrev == "NM" | state_abbrev == "OK" | state_abbrev == "UT" | state_abbrev == "WY"
replace circuit = 11 if state_abbrev == "AL" | state_abbrev == "FL" | state_abbrev == "GA"

* linear trends
egen circuit_biennum = group(circuit year)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18), absorb(circuit_biennum) cl(state)
outreg2 using Table_A31_circuit, excel replace label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(CircuitxTime FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18), absorb(circuit_biennum state) cl(state)
outreg2 using Table_A31_circuit, excel append label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(CircuitxTime FE, X, State FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) , absorb(circuit_biennum) cl(state)
outreg2 using Table_A31_circuit, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(CircuitxTime FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) , absorb(circuit_biennum state) cl(state)
outreg2 using Table_A31_circuit, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(CircuitxTime FE, X, State FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*************** Table A.32: Effect of Legislative Shock on FRASE Federal Regulation Index***************
*gen log_fed_reg=log(fed_reg)

reghdfe log_fed_reg shock_prov18, absorb(state year) cl(state) 
outreg2 using Table_A32_fedreg, excel replace label  ctitle(Fed Reg)  nocons addtext(State FE, X, Time FE, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

reghdfe log_fed_reg shock_prov18, absorb(state##c.year year) cl(state) 
outreg2 using Table_A32_fedreg, excel append label ctitle(Fed Reg)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X)  alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

***************Table A.33: Adjusting for FRASE Federal Regulation Index***************

bysort state : egen log_avgfed_reg=mean(log_fed_reg)

ivreghdfe growth_pc (log_provisions_18 = shock_prov18) , absorb(state year##c.log_avgfed_reg) cl(state)
outreg2 using Table_A33_fed_reg_adjusted, excel replace label keep(log_provisions_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Fed Reg x Time, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


ivreghdfe growth_pc (logX_diffcond_list_prov_18 = shock_cond_list_prov18 shock_non_cond_list_prov18) , absorb(state year##c.log_avgfed_reg) cl(state)
outreg2 using Table_A33_fed_reg_adjusted, excel append label keep(logX_diffcond_list_prov_18) ctitle(2SLS)  nocons addtext(State FE, X, Time FE, X, Fed Reg x Time, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)



